Which pair and time frame was used for the avove test? Any recommendations on settings? Thanks your for explaining.
//+------------------------------------------------------------------+
//| AutoTrade.mq4 |
//| Copyright ? 2006, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright 2006, Popular:-)"
#property link "scrivimi@mail.ru"
extern int Level_Warrants=20;
extern int Level_Profit=-2;
extern int End_minutes=20;
extern int unconditional_fixation=30;
extern int stabilization_items=25;
extern double lots=0.1;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
double pip=MarketInfo(Symbol(),MODE_TICKSIZE);
//----
if (OrdersTotal()==0)
{
double buy= Ask+Level_Warrants*pip;
double sell= Bid-Level_Warrants*pip;
int ticket1=OrderSend(Symbol(),OP_BUYSTOP,lots,buy,3,0,0,"buy",16384,CurTime()+End_minutes*60,Green);
int ticket2=OrderSend(Symbol(),OP_SELLSTOP,lots,sell,3,0,0,"buy",16384,CurTime()+End_minutes*60,Green);
}
if (OrdersTotal()>0)
{
for(int i=0;i<=OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
//----
ticket1=OrderTicket();
double profit1=OrderProfit();
double price1=OrderOpenPrice();
if(OrderType()==OP_BUY)
{
OrderSelect(i+1,SELECT_BY_POS,MODE_TRADES);
ticket2=OrderTicket();
if(OrderType()==OP_SELLSTOP)//---test closure on profit NO:1
{
OrderModify(OrderTicket(),OrderOpenPrice(),0,0,0,CLR_NONE);
if(profit1>Level_Profit&&MathAbs(Close[1]-Open[1])<=stabilization_items*pip)
{
OrderClose(ticket1,lots,Bid,3,CLR_NONE);
OrderDelete(ticket2);
}
if(MathAbs(Close[1]-Open[1])<=stabilization_items*pip&&MathAbs(Close[2]-Open[2])<=stabilization_items*pip)
{
OrderClose(ticket1,lots,Bid,3,CLR_NONE);
OrderDelete(ticket2);
}
if(profit1>=unconditional_fixation)
{
OrderClose(ticket1,lots,Bid,3,CLR_NONE);
OrderDelete(ticket2);
}
}
if(OrderType()==OP_SELL)
{//---immediately the closure of both
OrderClose(ticket1,lots,Bid,3,CLR_NONE);
OrderClose(ticket2,lots,Ask,3,CLR_NONE);
}
}
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_BUYSTOP)
{
OrderSelect(i+1,SELECT_BY_POS,MODE_TRADES);
ticket2=OrderTicket();
if(OrderType()==OP_SELL)//---verification closure on profits NO:2
{
OrderModify(ticket1,price1,0,0,0,CLR_NONE);
double profit2=OrderProfit();
if(profit2>Level_Profit&&MathAbs(Open[1]-Close[1])<=stabilization_items*pip)
{
OrderClose(ticket2,lots,Bid,3,CLR_NONE);
OrderDelete(ticket1);
}
if(MathAbs(Open[1]-Close[1])<=stabilization_items*pip&&MathAbs(Open[2]-Close[2])<=stabilization_items*pip)
{
OrderClose(ticket2,lots,Bid,3,CLR_NONE);
OrderDelete(ticket1);
}
if(profit2>=unconditional_fixation)
{
OrderClose(ticket2,lots,Bid,3,CLR_NONE);
OrderDelete(ticket1);
}
}
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| AutoTrade.mq4 |
//| Copyright ? 2006, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright 2006, Popular:-)"
#property link "scrivimi@mail.ru"
extern int Level_Warrants=20;
extern int Level_Profit=-2;
extern int End_minutes=20;
extern int unconditional_fixation=30;
extern int stabilization_items=25;
extern double lots=0.1;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
double pip=MarketInfo(Symbol(),MODE_TICKSIZE);
//----
if (OrdersTotal()==0)
{
double buy= Ask+Level_Warrants*pip;
double sell= Bid-Level_Warrants*pip;
int ticket1=OrderSend(Symbol(),OP_BUYSTOP,lots,buy,3,0,0,"buy",16384,CurTime()+End_minutes*60,Green);
int ticket2=OrderSend(Symbol(),OP_SELLSTOP,lots,sell,3,0,0,"buy",16384,CurTime()+End_minutes*60,Green);
}
if (OrdersTotal()>0)
{
for(int i=0;i<=OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
//----
ticket1=OrderTicket();
double profit1=OrderProfit();
double price1=OrderOpenPrice();
if(OrderType()==OP_BUY)
{
OrderSelect(i+1,SELECT_BY_POS,MODE_TRADES);
ticket2=OrderTicket();
if(OrderType()==OP_SELLSTOP)//---test closure on profit NO:1
{
OrderModify(OrderTicket(),OrderOpenPrice(),0,0,0,CLR_NONE);
if(profit1>Level_Profit&&MathAbs(Close[1]-Open[1])<=stabilization_items*pip)
{
OrderClose(ticket1,lots,Bid,3,CLR_NONE);
OrderDelete(ticket2);
}
if(MathAbs(Close[1]-Open[1])<=stabilization_items*pip&&MathAbs(Close[2]-Open[2])<=stabilization_items*pip)
{
OrderClose(ticket1,lots,Bid,3,CLR_NONE);
OrderDelete(ticket2);
}
if(profit1>=unconditional_fixation)
{
OrderClose(ticket1,lots,Bid,3,CLR_NONE);
OrderDelete(ticket2);
}
}
if(OrderType()==OP_SELL)
{//---immediately the closure of both
OrderClose(ticket1,lots,Bid,3,CLR_NONE);
OrderClose(ticket2,lots,Ask,3,CLR_NONE);
}
}
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_BUYSTOP)
{
OrderSelect(i+1,SELECT_BY_POS,MODE_TRADES);
ticket2=OrderTicket();
if(OrderType()==OP_SELL)//---verification closure on profits NO:2
{
OrderModify(ticket1,price1,0,0,0,CLR_NONE);
double profit2=OrderProfit();
if(profit2>Level_Profit&&MathAbs(Open[1]-Close[1])<=stabilization_items*pip)
{
OrderClose(ticket2,lots,Bid,3,CLR_NONE);
OrderDelete(ticket1);
}
if(MathAbs(Open[1]-Close[1])<=stabilization_items*pip&&MathAbs(Open[2]-Close[2])<=stabilization_items*pip)
{
OrderClose(ticket2,lots,Bid,3,CLR_NONE);
OrderDelete(ticket1);
}
if(profit2>=unconditional_fixation)
{
OrderClose(ticket2,lots,Bid,3,CLR_NONE);
OrderDelete(ticket1);
}
}
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
247817:
Which pair and time frame was used for the avove test? Any recommendations on settings? Thanks your for explaining.
the above was translated, try your best to understand.
Which pair and time frame was used for the avove test? Any recommendations on settings? Thanks your for explaining.
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
Autotrade:
Author: John Smith