You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
/*[[ Name := breakout_advisor Author := none Link := none Lots := 1.00 Stop Loss := 15 Take Profit := 30 Trailing Stop := 0 ]]*/ DEFINES: Bars2Check(4),BuyStop(8),SellStop(8),max_movement(60),chart(15); var: perClose(0),newClose(0),closehalf(0),durration(400); var: cnt(0),perHigh(0),perLow(0),adx(0); var: cordLow(0),cordHigh(0),bar(0); var: aBuyStop(0),aSellStop(0); var: current(0),halflots(0),X(0); //print(getGlobalVariable(symbol+period+AccountNumber+"buy")); If TotalTrades > 1 Then { for cnt = 1 to TotalTrades Begin If Ord(cnt,VAL_TYPE)=OP_BUYSTOP or Ord(cnt,VAL_TYPE)=OP_SELLSTOP then // this is a waiting order! { // check how long it exists in the trading terminal // time is counted in seconds: // 10 minutes = 600 seconds, 30 minutes = 1800, 1 hour = 3600, 1 day = 86400 If (CurTime-OrderValue(cnt,VAL_OPENTIME))>14000 then { DeleteOrder(OrderValue(cnt,VAL_TICKET),RED); Exit; }; }; end; }; if period != Chart then { Alert("This advisor only works on the ",chart," minute chart"); exit; }; //Print(Month,"/",Day,"/",Year," ",Symbol); if bar < bars then ( If Symbol = "USDCHF" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; If Symbol = "USDJPY" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; If Symbol = "GBPUSD" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; If Symbol = "EURUSD" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; If Symbol = "EURJPY" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; If Symbol = "EURCHF" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; If Symbol = "EURGBP" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; If Symbol = "USDCAD" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; If Symbol = "AUDUSD" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; If Symbol = "GBPJPY" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; If Symbol = "NZDUSD" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; If Symbol = "GBPCHF" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; If Symbol = "CHFJPY" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; If Symbol = "AUDJPY" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; If Symbol = "NZDUSD" then { cordHigh = Highest(MODE_HIGH,Bars2Check,Bars2Check); cordLow = Lowest(MODE_LOW,Bars2Check,Bars2Check); perHigh = High[cordHigh]; perLow = Low[cordLow]; }; SetGlobalVariable(period+"perhigh",perhigh); SetGlobalVariable(period+"perlow",perlow); //SetObjectText("R0.5_txt","R0.5 "+R0.5,"Arial",8,White); //MoveObject("R0.5_line",OBJ_HLINE,time[cnt],R0.5,time[cnt],R0.5,GreenYellow,1,STYLE_DOT); MoveObject("High",OBJ_HLINE,(LastTradeTime), perHigh,CurTime, perHigh,Green,2,STYLE_DOT); MoveObject("Low",OBJ_HLINE,(LastTradeTime), perLow,CurTime, perLow,Yellow,2,STYLE_DOT); Comment("Last ",Bars2Check," Bars High ",perHigh," Low ",perLow," ",(perHigh-perLow)/Point," Pips"); aBuyStop = perhigh+buystop*Point; aSellStop = perLow-sellstop*Point; bar=bars; }; perHigh = getGlobalVariable(period+"perhigh"); perLow = GetGlobalVariable(period+"perlow"); If perHigh-perLow < max_movement*point then { if TotalTrades =0 then //no open trsdes in any currency { SetOrder(OP_BUYSTOP,Lots,aBuyStop,3,abuystop-StopLoss*Point,abuyStop+TakeProfit*Point,blue); exit; }; if TotalTrades =1 and OrderValue(1,VAL_SYMBOL) = Symbol) and OrderValue(1,val_type) = OP_BUYstop then //only one open trade is in this currency and it's a buy stop { SetOrder(OP_SELLSTOP,Lots,asellStop,3,asellstop+StopLoss*Point,asellStop-TakeProfit*Point,blue); exit; }; current=0; /////Count how many open tickets in this currency for cnt = 1 to TotalTrades Begin if ord(cnt,val_symbol) = Symbol then { Current = Current +1; }; end; /////Count how many open tickets in this currency cnt=0; if current = 0 then //no open trades in this currency { SetOrder(OP_BUYSTOP,Lots,aBuyStop,3,abuystop-StopLoss*Point,abuyStop+TakeProfit*Point,blue); exit; }; if current = 1 then //means one open trade in this currency for cnt = 1 to TotalTrades Begin // Print(Symbol," ",cnt); if OrderValue(cnt,VAL_SYMBOL) = Symbol) and OrderValue(cnt,val_type) = OP_BUYstop then //only one open trade is in this currency and it's a buy stop { SetOrder(OP_SELLSTOP,Lots,asellStop,3,asellstop+StopLoss*Point,asellStop-TakeProfit*Point,blue); exit; }; end; }; /* If TotalTrades> 0 then { for cnt = 1 to TotalTrades Begin //Print("Ticket Number ",ord(cnt,val_ticket)," Profitable ",ord(cnt,val_profit)," ",(TakeProfit-1)*(-1*ord(cnt,VAL_COMMISSION))); if ord(cnt,val_comment)="" and ord(cnt,VAL_SYMBOL) = symbol and (ord(cnt,val_profit))>=(TakeProfit-1)*(-1*ord(cnt,VAL_COMMISSION)) then { halflots = floor(ord(cnt,val_lots)/2); if ord(cnt,VAL_TYPE)=OP_BUY then { CloseOrder(ord(cnt,VAL_TICKET),halflots,Bid,3,Red); Exit; }; if ord(cnt,VAL_TYPE)=OP_SELL then { //Print("Ticket Number ",ord(cnt,val_ticket)," Profitable ",ord(cnt,val_profit)," ",(TakeProfit-1)*(-1*ord(cnt,VAL_COMMISSION))); CloseOrder(ord(cnt,VAL_TICKET),halflots,Ask,3,Red); Exit; }; }; end; }; */ ////////////////////////////////////////////////////////// /////////////////////////Special Stop Los Code ///////////////////// ////////////////////////////////////////////////////////// /* If TotalTrades > 0 then { for cnt = 1 to TotalTrades Begin if ord(cnt,VAL_SYMBOL)= Symbol then { If Ord(cnt,VAL_TYPE)=OP_BUY then { /////////////////// If ord(cnt,val_comment)!="" and (CurTime-OrderValue(cnt,VAL_OPENTIME))< 120 then //this trade has already had 1/2 the ticket closed { Print("half of trade was closed less than two minutes ago"); If ord(cnt,val_stoploss) != Ord(cnt,VAL_OPENPRICE) Then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),Ord(cnt,VAL_OPENPRICE),Ord(cnt,VAL_TAKEPROFIT),Red); Exit; }; }; };// End of BUY If Ord(cnt,VAL_TYPE)=OP_SELL then { /////////////////// /////////////////// If ord(cnt,val_comment)!="" and (CurTime-OrderValue(cnt,VAL_OPENTIME))< 120 then //this trade has already had 1/2 the ticket closed { Print("half of trade was closed less than two minutes ago"); If ord(cnt,val_stoploss) != Ord(cnt,VAL_OPENPRICE) Then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),Ord(cnt,VAL_OPENPRICE),Ord(cnt,VAL_TAKEPROFIT),Red); Exit; }; }; };//End of Sell }; End; }; */ ////////////////////////////////////////////////////////// /////////////////////////Trailing Stop Code ///////////////////// ////////////////////////////////////////////////////////// If TotalTrades > 0 then { for cnt = 1 to TotalTrades Begin If Ord(cnt,VAL_TYPE)=OP_BUY then { /////////////////// If Ord(cnt,VAL_SYMBOL)= Symbol then { If Ord(cnt,VAL_OPENPRICE) + TrailingStop*Point < Bid Then { If Ord(cnt,VAL_STOPLOSS)<(Bid-TrailingStop*Point) then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE), Bid-TrailingStop*Point,Ord(cnt,VAL_TAKEPROFIT),Red); Exit; }; }; If Ord(cnt,VAL_STOPLOSS) = 0 Then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE), Ord(cnt,VAL_OPENPRICE)-StopLoss*Point,0,Red); Exit; }; }; };// End of BUY If Ord(cnt,VAL_TYPE)=OP_SELL then { /////////////////// If Ord(cnt,VAL_SYMBOL)= Symbol then { If Ord(cnt,VAL_OPENPRICE) - TrailingStop*Point > Ask Then { If Ord(cnt,VAL_STOPLOSS)>(Ask+TrailingStop*Point) then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE),Ask+TrailingStop*Point, Ord(cnt,VAL_TAKEPROFIT),White); Exit; }; }; If Ord(cnt,VAL_STOPLOSS) = 0 Then { ModifyOrder(Ord(cnt,VAL_TICKET),Ord(cnt,VAL_OPENPRICE), Ord(cnt,VAL_OPENPRICE)+StopLoss*Point,0,Red); Exit; }; }; };//End of Sell End; };