//+------------------------------------------------------------------+ //| TrustFibs Entry | //| Copyright 2023, TrustFibs | //| http://www.TrustFibs.com | //+------------------------------------------------------------------+ #property copyright "TrustFibsCopyright © 2023" #property link "https://www.TrustFibs" #property version "3.00" #property description "TrustFibs Entry" #property strict input double StartingLots = 1.00; input double TakeProfit = 500; input double StopLoss=250; input int numberofpositions = 3; bool OpenBUY=True; bool OpenSELL=True; bool CloseBySignal=true; double StopLoss1=100; double TrailingStop=0; int RSIperiod=5; double BuyLevel=30; double SellLevel=70; bool AutoLot=false; double Risk=1; int MagicNumber=123; int Slippage=10; int OrderBuy,OrderSell; int ticket; int LotDigits; double Trail,iTrailingStop; string Koment="TrustFibs Entry Pro"; bool UseEquityStop = FALSE; double TotalEquityRisk = 20.0; bool UseTrailingStop = FALSE; bool UseTimeOut = FALSE; // double MaxTradeOpenHours = 48.0; // double PriceTarget, StartEquity, BuyTarget, SellTarget; double AveragePrice, SellLimit, BuyLimit; double LastBuyPrice, LastSellPrice, Spread; bool flag; string EAName=""; int timeprev = 0, expiration; double iLots; double PipStepE; int cnt = 0, total; double Stopper = 0.0; bool TradeNow = FALSE, LongTrade = FALSE, ShortTrade = FALSE; double PriceTarget_Hilo, StartEquity_Hilo, BuyTarget_Hilo, SellTarget_Hilo, Balans, Sredstva ; bool NewOrdersPlaced = FALSE; double AccountEquityHighAmt, PrevEquity; string txt,txt1; string txt2=""; string txt3=""; string txt4=""; int init() { ObjectDelete("Ask1"); ObjectCreate("Ask1",OBJ_LABEL,0,0,1.0); ObjectSet("Ask1", OBJPROP_CORNER, 1); ObjectSet("Ask1", OBJPROP_XDISTANCE, 400); ObjectSet("Ask1", OBJPROP_YDISTANCE, 16); ObjectSetText("Ask1"," "+txt2+"",15,"Impact",Red); ObjectDelete("Ask"); ObjectCreate("Ask",OBJ_LABEL,0,0,1.0); ObjectSet("Ask", OBJPROP_CORNER, 3); ObjectSet("Ask", OBJPROP_XDISTANCE, 240); ObjectSet("Ask", OBJPROP_YDISTANCE, 55); ObjectSetText("Ask"," "+txt3+"",16,"Impact",Red); ObjectDelete("Ask2"); ObjectCreate("Ask2",OBJ_LABEL,0,0,1.0); ObjectSet("Ask2", OBJPROP_CORNER, 1); ObjectSet("Ask2", OBJPROP_XDISTANCE, 110); ObjectSet("Ask2", OBJPROP_YDISTANCE, 16); ObjectSetText("Ask2","Trust FIBS ENTRY (c)"+txt4+"",15,"Impact",Red); return(0); } int deinit() { return(0); } int start() { ChartSetInteger(0,CHART_COLOR_FOREGROUND, clrBlack); ChartSetInteger(0,CHART_COLOR_BACKGROUND, clrWhite); ChartSetInteger(0,CHART_COLOR_GRID, clrNONE); ChartSetInteger(0,CHART_COLOR_CHART_UP, clrBlack); ChartSetInteger(0,CHART_COLOR_CHART_DOWN, clrBlack); ChartSetInteger(0,CHART_COLOR_CANDLE_BULL, clrDeepSkyBlue); ChartSetInteger(0,CHART_COLOR_CANDLE_BEAR, clrBlack); double stoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL); OrderBuy=0; OrderSell=0; for(int cnt=0; cnt0) { iTrailingStop=TrailingStop; if(TrailingStopTrail && Bid-OrderStopLoss()>Trail) { ticket=OrderModify(OrderTicket(),OrderOpenPrice(),tsbuy,OrderTakeProfit(),0,Blue); } if(OrderType()==OP_SELL && OrderOpenPrice()-Ask>Trail && (OrderStopLoss()-Ask>Trail || OrderStopLoss()==0)) { ticket=OrderModify(OrderTicket(),OrderOpenPrice(),tssell,OrderTakeProfit(),0,Blue); } } } } double rsi=iRSI(Symbol(),PERIOD_M1,RSIperiod,PRICE_OPEN,0); double rsi1=iRSI(Symbol(),PERIOD_M1,RSIperiod,PRICE_OPEN,1); double rsi2=iRSI(Symbol(),PERIOD_M5,RSIperiod,PRICE_OPEN,0); double rsi3=iRSI(Symbol(),PERIOD_M5,RSIperiod,PRICE_OPEN,1); if(OpenSELL && OrderSell <1 && rsiSellLevel && rsi3>SellLevel) OPSELL(); if(OpenBUY && OrderBuy <1 && rsi>BuyLevel && rsi2>BuyLevel && rsi1BuyLevel) OPBUY(); if(CloseBySignal) { if(OrderBuy>0 && rsiSellLevel && rsi3>SellLevel) CloseBuy(); if(OrderSell>0 && rsi>BuyLevel && rsi2>BuyLevel && rsi1BuyLevel) CloseSell(); } return(0); } void OPBUY() { double StopLossLevel; double TakeProfitLevel; if(StopLoss1>0) StopLossLevel=Bid-StopLoss1*Point; else StopLossLevel=0.0; if(TakeProfit>0) TakeProfitLevel=Ask+TakeProfit*Point; else TakeProfitLevel=0.0; ticket=OrderSend(Symbol(),OP_BUY,LOT(),Ask,Slippage,StopLossLevel,TakeProfitLevel,Koment,MagicNumber,0,DodgerBlue); } void OPSELL() { double StopLossLevel; double TakeProfitLevel; if(StopLoss1>0) StopLossLevel=Ask+StopLoss1*Point; else StopLossLevel=0.0; if(TakeProfit>0) TakeProfitLevel=Bid-TakeProfit*Point; else TakeProfitLevel=0.0; //--- ticket=OrderSend(Symbol(),OP_SELL,LOT(),Bid,Slippage,StopLossLevel,TakeProfitLevel,Koment,MagicNumber,0,DeepPink); } void CloseSell() { int total=OrdersTotal(); for(int y=OrdersTotal()-1; y>=0; y--) { if(OrderSelect(y,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && OrderMagicNumber()==MagicNumber) { ticket=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),5,Black); } } } void CloseBuy() { int total=OrdersTotal(); for(int y=OrdersTotal()-1; y>=0; y--) { if(OrderSelect(y,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderMagicNumber()==MagicNumber) { ticket=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),5,Black); } } } double LOT() { double lotsi; double ilot_max =MarketInfo(Symbol(),MODE_MAXLOT); double ilot_min =MarketInfo(Symbol(),MODE_MINLOT); double tick=MarketInfo(Symbol(),MODE_TICKVALUE); //--- double myAccount=AccountBalance(); //--- if(ilot_min==0.01) LotDigits=2; if(ilot_min==0.1) LotDigits=1; if(ilot_min==1) LotDigits=0; //--- if(AutoLot) { lotsi=NormalizeDouble((myAccount*Risk)/10000,LotDigits); } else { lotsi=StartingLots; } //--- if(lotsi>=ilot_max) { lotsi=ilot_max; } //--- return(lotsi); }