Simple Coding Help - No Promise.

KelvinHand

Well-Known Member
BELIEVE , IT DOESN'T WORK RIGHT , IT MOVE WITH NEXT CANDLES UNTIL IT FIX ITSELF, IN SIMPLE NO USE OF IT .

HOW TO BELIEVE IT ? IT MOVES WITH PRICE.

STEP 1:
Use below code:
Code:
SetBarsRequired( -2, -2 ); 
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();
for( i = 1; i < 5; i++ ) 
{ 

    TimeframeSet( i*in1Minute ); 
     O1 = Ref(O, -1);
H1 = Ref(H, -1); L1 = Ref(L, -1);
C1 = Ref(C, -1);     [B][COLOR="Red"]up = C1 > O1;[/COLOR][/B]
TimeframeRestore(); 
         
   VarSet( "M"+ i, TimeFrameExpand( up, i*in1Minute , expandPoint ) ); 
} 

for( i = 1; i < 5; i++ ) 
{                    
  m = VarGet( "M" + i );  [COLOR="DarkRed"]([COLOR="DarkSlateBlue"][COLOR="Red"]Since,we are only talking about numbers not specific number, so i didn't used  i ==2 here[/COLOR][/COLOR] )[/COLOR]
   { 
      for( b = 0; b < BarCount; b++ ) {
       if( M[b] )   PlotText(" "+(i), b, L[b]-1-(i), colorAqua);
}}}

STEP 2: Either see it in real time or Use Bar replay ..
Use your bar replay, you'll see it by yourself , numbers are moving to next candles , kindly see 3,4,5 numbers .


STEP 3:
http://imgur.com/6bMmpm8
In this, 4 number is moving with price. same number move for 3-4 candles before it fix it.
need more?
http://imgur.com/dAQcavt

http://imgur.com/oijXyXr
Need more?
let me know, i can show you more and more, simply bigger the number, more it moves before it fix itself.
OH! My God !!!!
Don't you know that BarCount -1 is always the current bar.:eek:

If you don't want to see the current bar, then use ref -1 and ref -2.

I don't use live data, I work on EOD, Writing code to help you, I can only show you the sample,
It is on your own initiative to solve problem.

2nd issue is you need to look into higher timeframe expand into the lower time frame, how it behave.


Pls don't wake me up any more.

I give up.
 
Last edited:
OH! My God !!!!
Don't you know that BarCount -1 is always the current bar.:eek:

If you don't want to see the current bar, then use ref -1 and ref -2.
Hello,
I've already used ref(,-1);
Code:
[COLOR="DeepSkyBlue"][COLOR="Red"]TimeframeSet( i*in1Minute ); 
     O1 = [COLOR="magenta"]Ref[/COLOR](O, -1);
H1 = [COLOR="magenta"]Ref[/COLOR](H, -1); L1 = [SIZE="3"][COLOR="Magenta"]Ref[/COLOR](L, -1);[/SIZE]
C1 = [COLOR="magenta"]Ref[/COLOR](C, -1);     [B]up = C1 > O1;[/B]
TimeframeRestore(); [/COLOR][/COLOR]
2nd issue is you need to look into higher timeframe expand into the lower time frame, how it behave.
timeframeexpand has three ways

expandpoint
expandlast
expandlast


expandfirst used when you have in preference "Start of the BAr"
expandlast used when you have in perference "End of the bar"

simply timeframeexpand align higher to lower tf.
Usually expandfirst is used way more than expandlast in general
There's nothing other than that ..


Since we are not seeing current as we've used ref( ,-1) .. it is still wandering with same way before it fix itself.

http://imgur.com/6bMmpm8

Intraday data: www. 4shared .com /office/7JJmG3okce/NIFTY.html (google drive or this is used for mode of sharing as i've seen in many posts , i have september intraday minute data , I will delete it, if it's not appropriate) I am doing it because OP don't use or have intraday data.



I feel that, answer would be :

Since amibroker uses format ( not exact number of bar ending timing .)
Bar start from 1:00 and finish it on 1:59
Second bar 2:00 to 2:59


I don't know, what should i say? If people call it argument or ...?
How can you do that ? you know that candlestick is mostly used and if you make timing like that .. All analysis go in vain ... upper calculation is only minute ..


I do think your advice would be ,
First make all hft candle start and finish it round figure ??
start from 2:00 and finish with 3:00
second 3:01 to 4:00


Do you think ,it could solve issue?

Next advice would be probably use Datetimeadd function to do add something to make it round number (Do we add 0.01). ??


Code:
[SIZE="5"][COLOR="Red"]WE HAVE TO WRITE SOMETHING HERE FIRST, THAT  
MAKE ALL START AND FINISH CANDLE AS ROUND FIGURE  ?? OR ...??[/COLOR][/SIZE]

//
SetBarsRequired( -2, -2 ); 
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();
for( i = 1; i < 5; i++ ) 
{ 

    TimeframeSet( i*in1Minute ); 
     O1 = Ref(O, -1);
H1 = Ref(H, -1); L1 = Ref(L, -1);
C1 = Ref(C, -1);     up = C1 > O1;
TimeframeRestore(); 
         
   VarSet( "M"+ i, TimeFrameExpand( up, i*in1Minute , expandPoint ) ); 
} 

for( i = 1; i < 5; i++ ) 
{                    
  m = VarGet( "M" + i );  (Since,we are only talking about numbers not specific number, so i didn't used  i ==2 here )
   { 
      for( b = 0; b < BarCount; b++ ) {
       if( M[b] )   PlotText(" "+(i), b, L[b]-1-(i), colorAqua);
}}}
 
Last edited:
Hello dear friend,

I'm trying to code a trading strategy as below:

Buy when:
1. you have three days of increasing volume in a row in past three days (over any day of past 3 days) &
2. Volume has been greater than MA(V,60) at least one day in past three days &
3. RSI is less than or equal to 40 at least one day in past three days &
4. Price is lower than BBandBot(C,50,1)

Sell when:
Price is higher than BBandTop(C,50,6);

I have created the below code but it is not really working :(. I was wondering if you could kindly have a look on it.

SetTradeDelays (0,0,0,0);
SetOption(“maxopenpositions”,20);
SetPositionSize(5,spsPercentOfEquity);

Volumeincrease = IIf (V > Ref(V,-1) AND Ref(V,-1)>Ref(V,-2),True,False);
Volumeincrease1 = IIf(Ref(V,-1)>Ref(V,-2) AND Ref(V,-2)>Ref(V,-3),True, False);
Volumeincrease2 = IIf(Ref(V,-2)>Ref(V,-3)AND Ref(V,-3)>Ref(V,-4),True,False);

Volumegreatness = IIf(V>MA(V,60) OR Ref(V,-1)>Ref(MA(V,60),-1) OR Ref(V,-2)>Ref(MA(V,60),-2),1,-1);

RSIvalue = IIf(RSI(9)<=40 OR Ref(RSI(9),-1)<=40 OR Ref(RSI(9),-2)<=40,1,-1); //do we have the RSI(9) under 40 in past 3 days

bollitop=BBandTop(C,50,6);
bolibot=BBandBot(C,50,1);

Buy = C<=bolibot AND RSIvalue>=1 AND Volumegreatness>=1 OR Volumeincrease =True OR Volumeincrease1 =True OR Volumeincrease2 =True;
Sell = C>=bollitop;

Thank you very much in advance!
 
Hello,
I've already used ref(,-1);
Code:
[COLOR="DeepSkyBlue"][COLOR="Red"]TimeframeSet( i*in1Minute ); 
     O1 = [COLOR="magenta"]Ref[/COLOR](O, -1);
H1 = [COLOR="magenta"]Ref[/COLOR](H, -1); L1 = [SIZE="3"][COLOR="Magenta"]Ref[/COLOR](L, -1);[/SIZE]
C1 = [COLOR="magenta"]Ref[/COLOR](C, -1);     [B]up = C1 > O1;[/B]
TimeframeRestore(); [/COLOR][/COLOR]


timeframeexpand has three ways

expandpoint
expandlast
expandlast


expandfirst used when you have in preference "Start of the BAr"
expandlast used when you have in perference "End of the bar"

simply timeframeexpand align higher to lower tf.
Usually expandfirst is used way more than expandlast in general
There's nothing other than that ..


Since we are not seeing current as we've used ref( ,-1) .. it is still wandering with same way before it fix itself.

http://imgur.com/6bMmpm8

Intraday data: www. 4shared .com /office/7JJmG3okce/NIFTY.html (google drive or this is used for mode of sharing as i've seen in many posts , i have september intraday minute data , I will delete it, if it's not appropriate) I am doing it because OP don't use or have intraday data.



I feel that, answer would be :

Since amibroker uses format ( not exact number of bar ending timing .)
Bar start from 1:00 and finish it on 1:59
Second bar 2:00 to 2:59


I don't know, what should i say? If people call it argument or ...?
How can you do that ? you know that candlestick is mostly used and if you make timing like that .. All analysis go in vain ... upper calculation is only minute ..


I do think your advice would be ,
First make all hft candle start and finish it round figure ??
start from 2:00 and finish with 3:00
second 3:01 to 4:00


Do you think ,it could solve issue?

Next advice would be probably use Datetimeadd function to do add something to make it round number (Do we add 0.01). ??


Code:
[SIZE="5"][COLOR="Red"]WE HAVE TO WRITE SOMETHING HERE FIRST, THAT  
MAKE ALL START AND FINISH CANDLE AS ROUND FIGURE  ?? OR ...??[/COLOR][/SIZE]

//
SetBarsRequired( -2, -2 ); 
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();
for( i = 1; i < 5; i++ ) 
{ 

    TimeframeSet( i*in1Minute ); 
     O1 = Ref(O, -1);
H1 = Ref(H, -1); L1 = Ref(L, -1);
C1 = Ref(C, -1);     up = C1 > O1;
TimeframeRestore(); 
         
   VarSet( "M"+ i, TimeFrameExpand( up, i*in1Minute , expandPoint ) ); 
} 

for( i = 1; i < 5; i++ ) 
{                    
  m = VarGet( "M" + i );  (Since,we are only talking about numbers not specific number, so i didn't used  i ==2 here )
   { 
      for( b = 0; b < BarCount; b++ ) {
       if( M[b] )   PlotText(" "+(i), b, L[b]-1-(i), colorAqua);
}}}
You still cannot get what Kelvin's trying to tell u.

when you do plottext using for( b = 0; b < BarCount; b++ ) it count from 0 to BarCount-1
BarCount-1 is the current bar you see. so you should change to for( b = 0; b < BarCount-1; b++ ) to avoid the current bar.
then You can try use up= C>O to test out.
 
Last edited:

PUCHU_2500

Well-Known Member
AFL, any kind of query or help about afl, post here......

KINDLY HELP ME IN THIS

LookBack = Param("Lookback", 13, 2, 100 );
Smooth1 = Param("Smooth 1", 25, 1, 100 );
Smooth2 = Param("Smooth 2", 2, 1, 100 );

HH = HHV( H, LookBack );
LL = LLV( L, LookBack );

StoMom = 100 * EMA( EMA( C - 0.5 * ( HH + LL ), Smooth1 ), Smooth2 ) /
( 0.5 * EMA( EMA( HH - LL, Smooth1 ), Smooth2 ) );

Plot(StoMom, _DEFAULT_NAME(), ParamColor("Color", ColorCycle ) );

HOW TO INCERT THE STOCHOSTIC MOMENTUM INDICATOR IN CANDLESTICK CHART
 
is it possible to have a second installation of amibroker in D drive while already having one installed in C drive?? is it possible to run both at the same time?? PLEASE HELP..
 

candle

Well-Known Member
is it possible to have a second installation of amibroker in D drive while already having one installed in C drive?? is it possible to run both at the same time?? PLEASE HELP..
The answer to your query is YES. You can run multiple instances.

You can also copy your installed folder in your pendrive and carry in your pocket where ever you go...:)
 
You still cannot get what Kelvin's trying to tell u.

when you do plottext using for( b = 0; b < BarCount; b++ ) it count from 0 to BarCount-1
BarCount-1 is the current bar you see. so you should change to for( b = 0; b < BarCount-1; b++ ) to avoid the current bar.
then You can try use up= C>O to test out.
When we use for( b = 0; b < BarCount; b++ )
BarCount-1 is the current bar

and use ref(,-1); for complete candle, not current candle..

Why doesn't it work with this way?
 
As per below pic.

I am stating number of elements , right?




If there are number under 1 and 4 ..
how many number of elements there? Answer 2

if number under it , is 1 , 3 and 4 ..
how many number of elements are there? Answer 3
We are counting how many times a number is there ..

I guess there is no confusion.
CONDITION: IF NUMBER OF ELEMENTS ARE 2 , PLOT SHAPE ON CANDLE.
( ANY TWO NUMBERS ARE SAME AS NUMBER OF ELEMENTS (1,2) (2,3) (3,4) (1,4) (2,4) (3,4) ... LIKE THAT EACH ONE OF THOSE HAS TWO NUMBER OF ELEMENTS .. i GUESS DIFFERNCE BETWEEN NUMBER OF ELEMENTS AND NUMBERING UNDER IT IS CLEAR? KINDLY SEE UPPER PICTURE AGAIN )



?
Code:
 for( b = 0; b < BarCount; b++ ) {
     [SIZE="2"] if([SIZE="2"][COLOR="Red"]Sum(b[i])= 2[/COLOR][/SIZE])PlotShapes( shapeCircle*up , colorGreen, 0, H, 45 );[/SIZE]
// [B]It's not working though [/B]
       if( M[b] )   PlotText(" "+(i), b, L[b]-1-(i), colorAqua);

Code:
[COLOR="Magenta"]SetBarsRequired( -2, -2 ); 
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();
for( i = 1; i < 5; i++ ) 
{ 

    TimeframeSet( i*in1Minute ); 
     O1 = Ref(O, -1);
H1 = Ref(H, -1); L1 = Ref(L, -1);
C1 = Ref(C, -1);     up = C1 > O1;
TimeframeRestore(); 
         
   VarSet( "M"+ i, TimeFrameExpand( up, i*in1Minute , expandPoint ) ); 
} 

for( i = 1; i < 5; i++ ) 
{                    
  m = VarGet( "M" + i ); [/COLOR]
   { 
      for( b = 0; b < BarCount; b++ ) {
  [SIZE="5"][COLOR="Red"]if(Sum(b[i])= 2)PlotShapes( shapeCircle*up , colorGreen, 0, H, 45 ); //IT'S NOT WORKING[/COLOR][/SIZE]
       if( M[b] )   PlotText(" "+(i), b, L[b]-1-(i), colorAqua);
}}}
SINCE IT MET WITH CONDITION: If NUMBER OF ELEMENTS ARE 2
WE MAKE SHAPE ON CANDLE

 
Last edited:
mtftrader


Code:
Cond1 = <Some boolean condition>;
Cond2 = <Some other boolean condition>;
Cond3 = <yet other boolean condition>;
.....
CondN = <altogether different boolean condition>;

ConditionSoup = Cond1 + Cond2 + Cond3 ..... + CondN;

PlotShapes((ConditionSoup == 2) * shapeCircle, colorGreen, 0, H, 45 );
 

Similar threads