Requests & Ideas (MQL5 only!) - page 34

 

By the way, when you test in the Strategy Tester (in visual mode) I recommend using the LifeHack Balance Equity indicator - you will be comfortable watching the balance and equity in Strategy Tester:

LifeHack Balance Equity in the Strategy Tester (in visual mode)

 

The final version of the project is published

GalacticExplosion

version "1.008"

Details in the project:

Forum on trading, automated trading systems and testing trading strategies

Requests & Ideas (MQL5 only!)

Vladimir Karputov , 2017.12.18 21:31

I chose the name of the adviser: "GalacticExplosion".

I created a public project "GalacticExplosion":

public project "GalacticExplosion"

To participate in the project, upgrade your terminal to the build of 1711.


 

Hey, So for example in PHP you can use:

$a="hey";
$var="a";

return ${$var}; // returns "hey"



Is this possible in MT5, i was unable to find out how? If not it would be useful to me.

Another request for debugging purposes; ability to record used vars in a block of code:

array=recordvars();
if (PriceDT[5].high>bb1up[5] && PriceDT[5].low < bb2dn[5]-(bb1up[5]-bb2dn[5]) && ..))
  {..}

endrecordvars(array);


// results:
// array["priceDT[5].high"][value]
// array["bb1up[5]"][value]

Would be useful to me for faster debugging purposes. Just loop through the array to print msgs. 

Thanks for reading & have a blessed day.

 
Barteld Bosma :

Hey, So for example in PHP you can use:

$a= "hey" ;
$ var = "a" ;

 return ${$ var }; // returns "hey" 

Is this possible in MT5, i was unable to find out how? If not it would be useful to me.

***


Try this script:

//+------------------------------------------------------------------+
//|                                                      Test_en.mq5 |
//|                              Copyright © 2017, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2017, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.000"
#property script_show_inputs
input string a="hey";
string var="";
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+ 
void OnStart()
  {
   var=a;
   Print(var); // print "hey" on journal tab
  }
//+------------------------------------------------------------------+
Files:
Test_en.mq5  2 kb
 
Vladimir Karputov:

The final version of the project is published

GalacticExplosion

version "1.008"

Details in the project:


Hi Vladimir,


Thank you so much for this, I can hardly express myself. I wish you a blessed week and holidays.

 

Pardon my ambiguity/ lack of proper explanation.

The intention is to be able to reference to the name of a string/array/etc using a string directly. 

so 

string $a="q";
string $b="w";

string v1="a";
string v2="b";


Print ${$v1}  //output q
Print ${$v2}  //output w

It's called variable variables.

http://php.net/manual/en/language.variables.variable.php Please review this page incase i'm still unable to clarify myself properly.

 
Barteld Bosma :

Pardon my ambiguity/ lack of proper explanation.

The intention is to be able to reference to the name of a string/array/etc using a string directly. 

so 

It's called variable variables.

http://php.net/manual/en/language.variables.variable.php Please review this page incase i'm still unable to clarify myself properly.


The variable name is a constant. The name of the variable is unchanged.

 
ajsupernova :
Hello! Once again, thank you so much for this opportunity! Below is my request.

I’m wanting an EA that allows me to trade using a zone-based strategy. A zone is essentially a price area at which one usually believes price is going to reverse. We commonly find them in trading referred to as “price reversal zones”, “pivots” or “supply/demand zones”. 

When I’m trading in a zone, I usually draw out the price at which I’m willing to buy/sell into the zone (this is my entry price) and the price that I will exit the trade if the price of the asset is not moving in my desired direction (this is my stop loss price). Additionally, I set a target for where I think price will go if it is successful in reversing.

As of right now, to get the lowest risk entry, I have to literally sit and watch price. I set price alerts in my platform and then once price crosses my alert price, I have to be there to place an order. This order is usually a buy stop or sell stop.

I only want to enter trades when price actually reverses and exits the zone in my desired direction. We call that a “confirmation entry” because price moves into my order from within the zone. I don’t want to have to sit and wait for price to enter the zone and then place the orders. I want the EA to do this for me.

I want an EA that will allow me to designate all of the necessary variables, then that places an order when price crosses the activation price that I set. Additionally, I want to be able to use two protective stops. One standard stop loss that sits at a certain pre-defined price (usually a few pips below the zone) and the second one would be a trailing stop that allows for partial take profits and closes based on if price returns to trigger the trailing stop.

Here’s the specs…

  1. Be able to Input if the order is a buy/sell. 
  2. I want to input the lot size of the trade. 
  3. I want to input the asset to trade, i.e. EUR/USD, XAGUSD, a stock, commodity, or whatever else I’m trading.
  4. Input the near current price zone line, i.e. the price at which price needs to cross in order for the EA to place my buy/sell stop order. We can call this the "activation price", or "proximal zone price”.
  5. Input the far from current price zone line, i.e. the price at which the EA will cancel my buy/sell stop order if price crosses this line. We can call this the "invalidation price" or the "distal zone price”.
  6. Input the actual purchase price, i.e. the price at which the order should be placed if price crosses the activation price line. —> This is the buy/sell stop order.
  7. Input the standard stop loss/protective stop price for the buy/sell stop order to be placed.
  8. Input the target price of the buy/sell stop order that will be placed.
  9. Set if there should be a trailing stop or not.
  10. Set the number of pips for the trailing stop.
  11. Set the partial lot size that should be closed if price returns to the level of the trailing stop.
  12. The standard stop loss closes any remaining portion of the lot size if price returns to the level of the standard stop. The standard stop can be moved up and adjusted as usual.
  13. I’d like to have an ID number or Unique identifier for the relating "invalidation listeners" and entry orders set by the EA.
  14. If the market price reaches my pending order entry price and fills the order, the EA should cancel the “invalidation listener”.
  15. Once the trade is active in the market and the order filled, the EA should essentially be “off” for that trade and do nothing else. (The trailing stop could just be an instance of MT5’s standard trailing stop feature that is simply triggered by the order that the EA set, the trade itself does not need to be managed by the EA at all once activated.
  16. I’d like to be able to manually cancel any pending activation zones and be sure that the EA does not set any pending orders after doing so.
  17. I’d like to be able to see a full list of all of the pending activation zones that the EA is listening for and be able to manage (i.e. edit and delete) them.
  18. When managing the pending activation zones, there should be an alert if I’m about to delete and invalidation listener that is listening for a pending entry order that has yet to be filled.

The general idea here is that I want to minimize my risk with zone-based trading. I only want to get into a trade if it’s moving into my ideal price. And I do not want to put money on the table if it is not. Additionally, I want a trailing stop to secure profits immediately on the first pull back in any move that is a move in my desired direction.


In the image above, you’re seeing the actual pending MT5 order on the asset. This is what it would look like after the activation price has been reached and the EA places the order. Additionally though, the EA would be “listening” to price to ensure that if it crosses below the invalidation price (usually the same as the pending stop loss), that the order will be canceled and ruled out as invalidated.

Once price moves up into the buy price, the order would be activated with a trailing stop that is trailing by whatever number of pips I’ve indicated for that particular trade.

Do you believe that this is something you can code? If so, I would greatly appreciate it! This tool will help me minimize my risk and therefore increase my overall risk to reward ratio when trading.

Thanks!

Sorry, this is not interesting.

 
forextime8 :
It's just a info indicator for inform abt performance for current day.

And why do we need such an indicator? What is the idea of ​​using it?

 
Barteld Bosma :

Pardon my ambiguity/ lack of proper explanation.

The intention is to be able to reference to the name of a string/array/etc using a string directly. 

so 

It's called variable variables.

http://php.net/manual/en/language.variables.variable.php Please review this page incase i'm still unable to clarify myself properly.


Please see this: 

Macro substitution (#define)

Reason: