THE IDEA EXCHANGE - page 15

 
leonid553 писал (а) >>

It's not really about strategy. It is not difficult to insert an indicator.

But how to make expert's code work at OPENING PRICES programmatically?

In order to get the same result at running through ALL TICKETS, as at running through OPEN PRICES?

I haven't been able to do this yet.....

Being tied to time or volume sucks.... You can miss ticks

I do it this way.

into variables

int last_bar =0;

int start()

{

if (!IsNewBar()) return(0);

we get here only once on the first tick of a new bar. even if we missed the first tick of this bar

}

bool IsNewBar()

{

if (last_bar == Bars) return(false);
last_bar = Bars;
return(true);

}

 
kharko писал (а) >>

Catch the code... Opens and modifies at opening prices...

kharko and esmaster, thank you !

But I already wrote above on the previous page that such simple methods don't help. I tried it myself using both methods - I inserted a condition at opening prices into void start().

But apparently this is not enough ! As before, I get different, sharply opposite results when running by OPEN PRICES and by ALL TICKERS.

Probably, we need to trace the work "this way and that way" on the visual chart of the tester, then "feel the difference" and somehow change the work of other functions (besides start() )

//-----------------------------------------------------------
void start()
   {
   if (!IsTradeAllowed()) return;
   level_buy_stop=0;
   level_sell_stop=0;
   StepingStop();
   StepingPendings();
   if (TotalBuy ()==0 && TotalBuyStop ()==0) SetBuyStop ();
   if (TotalSell()==0 && TotalSellStop()==0) SetSellStop();
   Comment("Level Buy Stop=",level_buy_stop*Point,
    "\n","Level Sell Stop=",level_sell_stop*Point);
   }
//-----------------------------------------------------
void StepingStop()      {... .  }
//-----------------------------------------------------
void StepingPendings()  {... .  }
//-----------------------------------------------------
void SetBuyStop()    {... ...}

void SetSellStop()   {... ...}

int TotalBuy()       {  ...  }

int TotalBuyStop()   {...    }

int TotalSell()      {...... }

int TotalSellStop()  {.... ..}

// End
 
leonid553 different because fixing is at opening prices... we need to remove stops and profits altogether... and lock at opening prices...
 
leonid553 писал (а) >>

Hello all. I propose to use the so-called "Trend Detector". I wasn't expecting such a good result from this find of mine. Accidentally blinded it - put it in. I insert this part into almost every Expert Advisor and even a losing Expert Advisor yields some profit! It decreases the number of trades against the trend (mostly losing ones) and considerably increases the Profitability parameter of the Expert Advisor, often to at least two! This means that outside the optimization period we are much more likely to make a profit!

Here's the idea: we take BearsPower and BullsPower indicators (bulls power and bears power) and compare them to each other. But just compare them - it's a painful business. To do it programmatically is cumbersome. That's why I put MA on them and compare MA values on zero bar! Just add up these values = Delta. Further everything is simple. If DELTA ..>0 - the trend is up. Otherwise it is going downwards!

We just need to add to the condition to buy if ((Delta>=0) && ... ...

And in the Sell condition - if ((Delta<=0) && ... ...

In external parameters of any Expert Advisor, insert :

You don't have to insert it. But then you have to pick up these parameters and insert numerical values instead of variable names directly into the code. And here is the block itself :

Here is an example of how an EA works with the Trend Detector. We can see that in case of an up trend, the buy positions are opened, and vice versa.

Perhaps someone will have suggestions for improvement and refinement of the design. I would like to know how promising this trend detector will be.

I made the indicator according to the exact description and was surprised :) I got a lagging MACCD :)

Files:
 
Vinin писал (а) >>

вот и индикатор. _LineStat_1.mq4

На экран выводится количество баров.Выводится 3 сигмы. И если цена находится внутри одно СКО, то перерасчета не прноизводится, так как все в допустимых пределах. При пробитии, будет перерасчет.

There are three numerical values in the top left corner of the chart after N=150 (number of bars). Please tell me what they mean and how to use them

 
Figar0 писал (а) >>

My idea, I'll get started...

The idea is old, but for some reason not widespread in implementation, I use it myself, it works quite well with some strategies. Exit only by Take Profit. If you guessed right from the direction - get initially planned take profit, if not - tighten TP following the price (you can use different algorithms - loops, rubber bands, level indicators, etc.) In this case, the take may be negative, but it is often much more profitable than the triggering of a stop loss. A safety stoploss to limit huge losses is not prohibited.

1) I also use this in daytrading, and call it "Trailing Profit". However, I do not use trailing stop for active trading, because it is a way to minimize profit.

2) I also have a small idea. Sometimes it is unpleasant to watch the profit decrease and move the open position to the loss, after we missed 1-2 points to TP. That is why I have started to practice the following solution: when 1-2 pips are left before TP, I send a request to close the order. In this case order is either closed on TP, or not closed at all (as the price rebounded and went out of area of slippage), but orders are closed more often and it brings more profit for a period.

 
rid писал (а) >>

There are three numerical values in the left corner of the chart after N=150 (number of bars). Please tell me what they mean and how to use them

Delta equals the difference between left and right midline.

3*S equals three standard deviations

n is how many bars the regression channel has not been recalculated.

If price on the last bar is within 3 standard deviations (+-1.5), no recalculation is performed.

I had to go into the code (the indicator is too old, it was developed in 2006).

If you want to change outputted information, you are welcome

 
OK! Thank you.
 
Vinin писал (а) >>

I had to go into the code (the indicator is too old, it was made in 2006)

If you want to change the displayed information, you're welcome to do so.

There is one modest request. If you don't mind. How to WRITE an iCustom expression for this indicator?

At least for EVERY yellow line and for the centre line ?

I can't figure it out on my own!

 
rid писал (а) >>

There is one humble request. If it's not difficult. How to RECORD the iCustom expression for this indicator?

At least for EVERY yellow line and for the centre line ?

I can not figure it out myself!

If you need it, I can search in the stacks for the right indicator or make one. And how to work with it in the Expert Advisor - just all the calculations in it (Expert Advisor).

Reason: