Is this the right place to ask for scripts?

 
Just wondering if this is the right place to put this or not.

I'm wondering if there's a script/way to auto put a stop loss as soon as I open an order without manually putting it in (sometimes I just want to get in) but say I want a 20 pip stop loss as that's my 2% / trade max (just an example) is there a way to have it set itself as soon as I take the trade (don't want to punch in all those numbers manually) and then be able to adjust it as I see fit as my trade moves?

Is this the right thread to ask? Does something like this exist? I'm not new to trading but I am new to the idea of using scripts, basically I'm trying stop crazy reversals due to manipulation ect.
 
Jory M-P: Just wondering if this is the right place to put this or not. I'm wondering if there's a script/way to auto put a stop loss as soon as I open an order without manually putting it in (sometimes I just want to get in) but say I want a 20 pip stop loss as that's my 2% / trade max (just an example) is there a way to have it set itself as soon as I take the trade (don't want to punch in all those numbers manually) and then be able to adjust it as I see fit as my trade moves? Is this the right thread to ask? Does something like this exist? I'm not new to trading but I am new to the idea of using scripts, basically I'm trying stop crazy reversals due to manipulation ect.

There should be something like that in the CodeBase. If not, then the Market. And if nothing suites you, you can always have something made for you in the Freelance section.

Please note however, that recommendations on Market products are not allowed in the forum, so you will have to do your own research.

 

I trade that way most of the time.

Create a triggerbuy.mq4 script:

void OnStart() {
//---
   string triggerbuyfile = "trigger_" + _Symbol + "_BUY_" + IntegerToString(AccountNumber()) +".txt";
   int filehandle=FileOpen(triggerbuyfile,FILE_WRITE|FILE_TXT|FILE_COMMON);
   FileWrite(filehandle,TimeCurrent(),Symbol(), EnumToString(ENUM_TIMEFRAMES(_Period)));
   FileClose(filehandle);
}


Then a triggersell.mq4 script:

void OnStart() {
//---
   string triggersellfile = "trigger_" + _Symbol + "_SELL_" + IntegerToString(AccountNumber()) +".txt";
   int filehandle=FileOpen(triggersellfile,FILE_WRITE|FILE_TXT|FILE_COMMON);
   FileWrite(filehandle,TimeCurrent(),Symbol(), EnumToString(ENUM_TIMEFRAMES(_Period)));
   FileClose(filehandle);
}


Then a triggerclose.mq4 script:

void OnStart() {
//---
        string triggerclosefile = "triggerclose_" + _Symbol + "_" + IntegerToString(AccountNumber()) +".txt";
        int filehandle=FileOpen(triggerclosefile,FILE_WRITE|FILE_TXT|FILE_COMMON);
        FileWrite(filehandle,TimeCurrent(),Symbol(), EnumToString(ENUM_TIMEFRAMES(_Period)));
        FileClose(filehandle);
}


Assign a keyboard shortcut to each one.


Then your EA does this:

int OnInit()    {
   EventSetMillisecondTimer(100);

   triggerbuyfile    = "trigger_" + _Symbol + "_BUY_" + IntegerToString(AccountNumber()) +".txt";
   triggersellfile   = "trigger_" + _Symbol + "_SELL_" + IntegerToString(AccountNumber()) +".txt";
   triggerclosefile  = "triggerclose_" + _Symbol + "_" + IntegerToString(AccountNumber()) +".txt";
   if (FileIsExist(triggerbuyfile, FILE_COMMON))    {FileDelete(triggerbuyfile, FILE_COMMON);}
   if (FileIsExist(triggersellfile, FILE_COMMON))   {FileDelete(triggersellfile, FILE_COMMON);}
   if (FileIsExist(triggerclosefile, FILE_COMMON))  {FileDelete(triggersellfile, FILE_COMMON);}

   StopLossValue = 20;
   TakeProfitValue = 40;

   return(INIT_SUCCEEDED);
}

void OnTimer()    {RunLoop();}
void OnTick()     {RunLoop();}

void RunLoop()  {

   if (isTradeRunning == true)  {monitorTrade(); return;}

   if (isTradeRunning == false)  {
        if (FileIsExist(triggerbuyfile, FILE_COMMON))    {orderOpen("buy");  return;}
        if (FileIsExist(triggersellfile, FILE_COMMON))   {orderOpen("sell"); return;}
   }
}

void orderOpen(string action) {

   if (FileIsExist(triggerbuyfile, FILE_COMMON))    {FileDelete(triggerbuyfile, FILE_COMMON);}
   if (FileIsExist(triggersellfile, FILE_COMMON))   {FileDelete(triggersellfile, FILE_COMMON);}

   if (isTradeRunning == true)   {return;}

   RefreshRates();

   if (action == "buy")    {StopLoss = Bid - StopLossValue; TakeProfit = priceNow + TakeProfitValue;}
   if (action == "sell")   {StopLoss = Ask + StopLossValue; TakeProfit = priceNow - TakeProfitValue;}

   if   (action == "buy")    {orderTicket = OrderSend (Symbol(), OP_BUY,  LotSize, Ask, 2, StopLoss, TakeProfit, "", 0, 0, CLR_NONE);}
   if   (action == "sell")   {orderTicket = OrderSend (Symbol(), OP_SELL, LotSize, Bid, 2, StopLoss, TakeProfit, "", 0, 0, CLR_NONE);}

   if   (OrderSelect(orderTicket1, SELECT_BY_TICKET, MODE_TRADES) == true)      {
        isTradeRunning = true;
   } else {
        Print("Last error on " + _Symbol + ": " + IntegerToString(GetLastError()));
   }
}

void monitorTrade()     {

   if (FileIsExist(triggerclosefile, FILE_COMMON))   {
        orderCloseRobot();
        FileDelete(triggerclosefile, FILE_COMMON);
        return;
   }
}

bool orderCloseRobot() {
   Print("I'll leave this as homework for you. :-) ");
   return;
}


There may be errors or omissions buy you should get the gist of it.