• Australian (ASX) Stock Market Forum

# Remap Problem - ideas??

Discussion in 'Software and Data' started by Steve C144, Aug 8, 2019.

1. ### Steve C144

Posts:
19
0
Joined:
Jun 17, 2019
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));

2. ### Trav.

Posts:
637
728
Joined:
Nov 27, 2017
@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

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(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));
```

3. ### Steve C144

Posts:
19
0
Joined:
Jun 17, 2019
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???

4. ### Trav.

Posts:
637
728
Joined:
Nov 27, 2017
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)

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));

Gringotts Bank likes this.

Posts:
19