Untitled
plain_text
19 days ago
3.7 kB
0
Indexable
Never
//+------------------------------------------------------------------+ //| SampleRSIcBot | //| Generated by BingAI | //| | //+------------------------------------------------------------------+ #property copyright "Generated by BingAI" #property link "https://www.bingai.ai" #property version "1.00" #property strict #include <Trade\Trade.mqh> #include <Indicators\Trend\SuperTrend.mqh> #include <Indicators\Trend\AverageTrueRange.mqh> input double LotSize = 1.0; input int SuperTrendPeriod10 = 10; input double SuperTrendMultiplier10 = 1.0; input int SuperTrendPeriod11 = 11; input double SuperTrendMultiplier11 = 2.0; input int SuperTrendPeriod12 = 12; input double SuperTrendMultiplier12 = 3.0; input double MinATR = 0.0001; input double StopLoss = 0.5; CSuperTrend SuperTrend10, SuperTrend11, SuperTrend12; CAverageTrueRange ATR; double LastBuyAdjustmentPrice = 0; double LastSellAdjustmentPrice = 100; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { SuperTrend10.Create(Symbol(),Period(),SuperTrendPeriod10,SuperTrendMultiplier10); SuperTrend11.Create(Symbol(),Period(),SuperTrendPeriod11,SuperTrendMultiplier11); SuperTrend12.Create(Symbol(),Period(),SuperTrendPeriod12,SuperTrendMultiplier12); ATR.Create(Symbol(),Period(),10,MODE_WMA); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { // Deinitialization logic here, if needed } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { if (SuperTrend10.UpTrendIsRising() && PositionsTotal()==0 && SuperTrend11.UpTrendIsRising() && SuperTrend12.UpTrendIsRising() && ATR.Result[0] > MinATR) { for(int i=PositionsTotal()-1; i>=0; i--) { ulong ticket = PositionGetTicket(i); if(PositionSelectByTicket(ticket)) { if(PositionClose(ticket)==false) Print("Error closing buy position: ", GetLastError()); } } double limitPrice = SymbolInfoDouble(_Symbol,SYMBOL_BID)+_Point; ulong ticket = BuyLimit(LotSize,limitPrice,0,"Buy",clrNONE); if(ticket>0) LastBuyAdjustmentPrice = 0; else Print("Error placing buy order: ", GetLastError()); } if (SuperTrend10.DownTrendIsFalling() && PositionsTotal()==0 && ATR.Result[0] > MinATR) { for(int i=PositionsTotal()-1; i>=0; i--) { ulong ticket = PositionGetTicket(i); if(PositionSelectByTicket(ticket)) { if(PositionClose(ticket)==false) Print("Error closing sell position: ", GetLastError()); } } double limitPrice = SymbolInfoDouble(_Symbol,SYMBOL_ASK)-_Point; ulong ticket = SellLimit(LotSize,limitPrice,0,"Sell",clrNONE); if(ticket>0) LastSellAdjustmentPrice = 100; else Print("Error placing sell order: ", GetLastError()); } }