Scripts: Long position

 

Long position:

A simple script that allows you to open a long position using the current price location with a specified Risk Percentage and Reward Ratio.

Author: Marcus Wyatt

 
The script doesn't work because the mentioned include files #include <Trade\Trade.mqh> are missing in the code.
#include <Trade\PositionInfo.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>

 
   double percentage   = RiskPercentage / 100;
   
   if(percentage > MAX_PERCENT) percentage = MAX_PERCENT;
   

   
   lots = (final_account_balance*(RiskPercentage/100.0))/(lots_size/leverage);
   //----
   return( lots );

In these lines of code you calculate the percentage and limit this but later in the calculation of lots_size you don't use the limited "percentage" value.

I don't think that this would be correct cause "percentage" is not used in the codesnippet anymore, pls check this. 

 
Kira27 #:
The script doesn't work because the mentioned include files #include <Trade\Trade.mqh> are missing in the code.
#include <Trade\PositionInfo.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>

Having switched on "algorithmic trading" in the terminal settings.))))))
 
this good option
 
i dont no