Australian (ASX) Stock Market Forum

Remap Problem - ideas??

Joined
17 June 2019
Posts
19
Reactions
0
Hello All,

Here is my code....if you run an exploration in Amibroker you will see four columns. The last colum is supposed to be the difference between the second and third....but no! It seems my remap is affecting the result, but I dont know how or why...if the remap lines are commented out, the calculation is correct...help please...TIA.
x = ROC (C, 10);
y = ROC (C, 20);
z = ROC (C, 30);

today = x + y + z;
OneDayAgo = Ref(today,-1);
TwoDaysago = Ref(today,-2);
change = onedayago-today;

today = Remap( today, LastValue( Lowest( today ) ), LastValue( Highest( today ) ), -1,1);
OneDayAgo = Remap( OneDayAgo, LastValue( Lowest( OneDayAgo ) ), LastValue( Highest( OneDayAgo ) ), -1,1);
TwoDaysago = Remap(TwoDaysago, LastValue( Lowest( TwoDaysago ) ), LastValue( Highest( TwoDaysago ) ), -1,1);
change = Remap( change, LastValue( Lowest( change ) ), LastValue( Highest( change ) ), -1,1);

Filter=1;
AddColumn(Twodaysago,"2 Days Ago ",1.2,textcolor=colorwhite,IIf(twodaysago>0,bkgndColor = colorgreen,colorred));
AddColumn(OneDayAgo,"1 Day Ago ",1.2,IIf(onedayago<twodaysago,textcolor=colorYellow,colorblack),IIf(onedayago>0,bkgndColor = colorgreen,colorred));
AddColumn(today,"Today ",1.2,IIf(today<onedayago,textcolor=colorYellow,colorWhite),IIf(today>0,bkgndColor = colorgreen,colorred));
AddColumn(change,"o/night change",1.2,IIf(today<onedayago,textcolor=colorYellow,colorwhite),IIf(change<0,bkgndColor = colorRed,colorGreen));
 
@Steve C144

I have had had a go with you formula and I have come up with the following that appears to work - well at least adds and subtracts correctly.

I have added 3 columns that helped me with checking today's value to make sure they added up correctly which it did not do in the original code. Probably something to do with data type, but I am no expert.

Hopefully this helps and you can clean up as require.

Cheers


upload_2019-8-8_16-59-7.png

Code:
x = ROC (C, 10);
y = ROC (C, 20);
z = ROC (C, 30);
/*
today = x + y + z;

OneDayAgo = Ref(today,-1);
TwoDaysago = Ref(today,-2);
change = onedayago-today;

today = Remap( today, LastValue( Lowest( today ) ), LastValue( Highest( today ) ), -1,1);
OneDayAgo = Remap( OneDayAgo, LastValue( Lowest( OneDayAgo ) ), LastValue( Highest( OneDayAgo ) ), -1,1);
TwoDaysago = Remap(TwoDaysago, LastValue( Lowest( TwoDaysago ) ), LastValue( Highest( TwoDaysago ) ), -1,1);
change = Remap( change, LastValue( Lowest( change ) ), LastValue( Highest( change ) ), -1,1);
*/
Filter=1;
AddColumn(x,"x",1.2,colorDefault, colorDefault, -1, null);
AddColumn(y,"y");
AddColumn(z,"z");

AddColumn(Ref(x,-2)+Ref(y,-2)+Ref(z,-2),"2 Days Ago ",1.2,textcolor=colorwhite,IIf(Ref(x,-2)+Ref(y,-2)+Ref(z,-2)>0,bkgndColor = colorgreen,colorred));
AddColumn(Ref(x,-1)+Ref(y,-1)+Ref(z,-1),"1 Day Ago ",1.2,IIf(Ref(x,-1)+Ref(y,-1)+Ref(z,-1)<Ref(x,-2)+Ref(y,-2)+Ref(z,-2),textcolor=colorYellow,colorblack),IIf(Ref(x,-1)+Ref(y,-1)+Ref(z,-1)>0,bkgndColor = colorgreen,colorred));
AddColumn(x+y+z,"Today ",1.2,IIf(x+y+z<Ref(x,-1)+Ref(y,-1)+Ref(z,-1),textcolor=colorYellow,colorWhite),IIf(x+y+z>0,bkgndColor = colorgreen,colorred));
AddColumn((Ref(x,-1)+Ref(y,-1)+Ref(z,-1))-(x+y+z),"o/night change",1.2,IIf(x+y+z<Ref(x,-1)+Ref(y,-1)+Ref(z,-1),textcolor=colorYellow,colorwhite),IIf((Ref(x,-1)+Ref(y,-1)+Ref(z,-1))-(x+y+z)<0,bkgndColor = colorRed,colorGreen));
 
Thant's awesome...thanks....any thoughts on the "remap" aspect...I want to get the results in a range of say -10 to 10 or similar???
 
my apologises as I did not read your post correctly, try this.......hopefully scaled correctly.

From existing range of -100 to 100

to new range -10 to 10

edit... I did not modify the coding at the end of the exploration line (IIF)

upload_2019-8-8_17-52-11.png

Code:
x = ROC (C, 10);
y = ROC (C, 20);
z = ROC (C, 30);

today = x + y + z;
OneDayAgo = Ref(today,-1);
TwoDaysago = Ref(today,-2);
change = onedayago-today;

today1 = Remap( today, -100, 100, -10, 10);
OneDayAgo1 = Remap( OneDayAgo, -100, 100, -10, 10);
TwoDaysago1 = Remap( TwoDaysago, -100, 100, -10, 10);
change1 = Remap( change, -100, 100, -10, 10);


Filter=1;
AddColumn(Twodaysago1,"2 Days Ago ",1.2,textcolor=colorwhite,IIf(twodaysago>0,bkgndColor = colorgreen,colorred));
AddColumn(OneDayAgo1,"1 Day Ago ",1.2,IIf(onedayago<twodaysago,textcolor=colorYellow,colorblack),IIf(onedayago>0,bkgndColor = colorgreen,colorred));
AddColumn(today1,"Today ",1.2,IIf(today<onedayago,textcolor=colorYellow,colorWhite),IIf(today>0,bkgndColor = colorgreen,colorred));
AddColumn(change1,"o/night change",1.2,IIf(today<onedayago,textcolor=colorYellow,colorwhite),IIf(change<0,bkgndColor = colorRed,colorGreen));
 
Top