Reversal from low to high

Hello,

I need help for following question:
How can I create a system for following condition:
Close > 4% higher then lowest low of beginning and when after the buy the highest high turn 4 % lower and vice versa.
Thanks for any help.

1 Like
Buy = C > Ref(Lowest(L), -1) * 1.04;
Sell = C < Ref(Highest(H),-1) * 0.96;
1 Like
cond1 = C > Ref(Lowest(L), -1) * 1.04;
cond2 = C < Ref(Highest(H),-1) * 0.96;

Buy = cond1;
Sell =cond2;
/* exrem is one method to remove surplus strade signals*/
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

Filter =1;

AddTextColumn( FullName(), "Company Name" );
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );
AddColumn( C, "Close", 1.2 );
AddColumn( Lowest(L), "Lowest", 1.2 );
AddColumn( Highest(H), "Highest", 1.2 );

it is not actually doing what I want.
It should buy if close is higher than 4% than the last lowest low and if the system is long it should sell if the highest high is lower than 4% and go long again if the last low after the exit is higher than 4%. Thanks for any help.

I am sorry but some of your explanations are completely useless because they are too imprecisely!

You are looking for free ride code so be precisely and detailed as much as possible!
(And BTW, free ride code is just supposed to give a nudge to get someone going. How about walking further by yourself?)

Lower than 4% of what?!

Beginning of what? Beginning of universe?

Which last low?!
There are galleys of lows available!
And here again higher than 4% of what?!

It's not a guessing show.

And if you compare levels at signal with price in result list you should actually output those levels instead of comparing apples to oranges.

lowlevel = Ref(Lowest(L), -1) * 1.04;
highlevel = Ref(Highest(H),-1) * 0.96;

cond1 = C > lowlevel;
cond2 = C < highlevel;

Buy = cond1;
Sell =cond2;
/* exrem is one method to remove surplus strade signals*/
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

Filter =1;

AddTextColumn( FullName(), "Company Name" );
AddColumn( IIf(Buy, 1, Null), "Buy", 1 );
AddColumn( IIf(Sell, 1, Null), "Sell", 1 );
AddColumn( C, "Close", 1.2 );
AddColumn( lowlevel, "entry level", 1.2 );
AddColumn( highlevel, "exit evel", 1.2 );

And if you say that something is not doing what it is intended to do then post example output besides of being precisely+detailed! Is all that so difficult? Oh wait... I know a possible reason for not doing so... it would take you more time on your hand... Sorry, but others' time is limited too.


Most important thing seems to be "I want..." there.

2 Likes

Sorry for my unclear definition.
But I got it.
The definion are following:
sellexit is when the closing price is 4 % lower than the last highest high of the buycondtion period
buyconditon is if the closing price is minimum 4 % above the lowest low after the sellexit.
It is like a trailing stop in both directions.
So if I am long I stay so long else the markets turns 4 % lower from the highest high since I bought , afterwards I mark every day the lowest low after the exit and if the close is higher than 4 % from this lowest low after the exit , I go long again.
Hopefully this is a clear description or if not tell me.

Sorry for my unclear definition.
But I got it.
The definion are following:
sellexit is when the closing price is 4 % lower than the last highest high of the buycondtion period
buyconditon is if the closing price is minimum 4 % above the lowest low after the sellexit.
It is like a trailing stop in both directions.
So if I am long I stay so long else the markets turns 4 % lower from the highest high since I bought , afterwards I mark every day the lowest low after the exit and if the close is higher than 4 % from this lowest low after the exit , I go long again.
Hopefully this is a clear description or if not tell me please.

// Description
//System go long if the Lowest Low  at the beginning period is 4 % higher 
//exit if the Highest High since Buy is 4 % lower.
//Go long again if the Low since Exit is 4 % higher again 

lowlevel = Ref(Lowest(L), -1) * 1.04;
highlevel = Ref(Highest(H),-1) * 0.96;

cond1 = C > lowlevel;
cond2 = C < highlevel;
 

 
Buy = cond1;
Sell =cond2;

highsinceBuy = HighestSince( Buy, High); 
 
/* exrem is one method to remove surplus strade signals*/
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
 
Filter =1;

AddTextColumn( FullName(), "Company Name" );
AddColumn( IIf(Buy, 1, Null), "Buy", 1 );
AddColumn( IIf(Sell, 1, Null), "Sell", 1 );
AddColumn( C, "Close", 1.2 );
AddColumn( lowlevel, "entry level", 1.2 );
AddColumn( highlevel, "exit evel", 1.2 );
AddColumn( Lowest(L), "LowestL", 1.2 );
AddColumn( Highest(H), "HighestH", 1.2 );
AddColumn( highsinceBuy, "HighestH", 1.2 );type or paste code here

Can someone help me to get better here. I don´t know where I have to set the
highsincebuy and low after the exit. Thanks for help.

 // Description
//System go long if the Lowest Low  at the beginning period is 4 % higher 
//exit if the Highest High since Buy is 4 % lower.
//Go long again if the Low since Exit is 4 % higher again 

lowlevel = Ref(Lowest(L), -1) * 1.04;
highlevel = Ref(Highest(H),-1) * 0.96;

cond1 = C > lowlevel;
cond1 = C > (LowestSince(Sell,Low,1) * 1.04);  // how can I set this right???
 
 
Buy = cond1;

cond2= low < (highestsince(buy,high,1)*0.96); 

Sell =cond2;
 

highsinceBuy = HighestSince( Buy, High); 
 
/* exrem is one method to remove surplus strade signals*/
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
 
Filter =1;

AddTextColumn( FullName(), "Company Name" );
AddColumn( IIf(Buy, 1, Null), "Buy", 1 );
AddColumn( IIf(Sell, 1, Null), "Sell", 1 );
AddColumn( C, "Close", 1.2 );
AddColumn( lowlevel, "entry level", 1.2 );
AddColumn( highlevel, "exit evel", 1.2 );
AddColumn( Lowest(L), "LowestL", 1.2 );
AddColumn( Highest(H), "HighestH", 1.2 );
AddColumn( highsinceBuy, "HighestH", 1.2 );

the exit works but not the entry it should buy from the beginning lowest low and start the new low counting after the exit.
Thanks for help.

to get clearer what I want.
Start
buy : Close > 4% of lowest low since begin to start
sell : Exit Close < 0.96* highest High since Buy
start the new low of the sell/exit and if the close is > 1.04* the lowest low after the exit buy again.
Could you give me an advise or an example. Thanks.

You can use code below as a starting point for your own coding:

ll = Low[ 0 ];
hh = High[ 0 ];

intrade = False;

Buy = Sell = 0;

for( i = 0; i < BarCount; i++ )
{
	if( NOT intrade )
	{
		if( Low[ i ] < ll ) ll = Low[ i ];

		if( Close[ i ] > 1.04 * ll )
		{
			Buy[ i ] = True;
			hh =  High[ i ];
			intrade = True;
		}
	}
	else
	{
		if( High[ i ] > hh ) hh = High[ i ];

		if( Close[ i ] < 0.96 * hh )
		{
			Sell[ i ] = True;
			ll = Low[ i ];
			intrade = False;
		}
	}
	
}
5 Likes

Thanks a lot. Now I understand a little bit more how I can solve this in a loop.